/** 递归实现深拷贝 */
function deepCopy(obj) {
    if (typeof obj !== 'object' && obj === null) {
        return obj;
    }
    const result = obj instanceof Array ? [] : {};
    for(const key in obj){
        if(obj.hasOwnProperty(key))
            result[key] = deepCopy(obj[key])
    }
    return result;
}

const obj = [1,3,2,[1,3]];
console.log(deepCopy(obj));

/** 实现深拷贝:不能对undefined,函数,symbol实现深拷贝 */
console.log(JSON.parse(JSON.stringify(obj)));
